/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "ADDF")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Addf.findAll", query = "SELECT a FROM Addf a"),
    @NamedQuery(name = "Addf.findByIdAdd", query = "SELECT a FROM Addf a WHERE a.addfPK.idAdd = :idAdd"),
    @NamedQuery(name = "Addf.findByIdPersonalInfo", query = "SELECT a FROM Addf a WHERE a.addfPK.idPersonalInfo = :idPersonalInfo"),
    @NamedQuery(name = "Addf.findByIdBranchenterprise", query = "SELECT a FROM Addf a WHERE a.addfPK.idBranchenterprise = :idBranchenterprise"),
    @NamedQuery(name = "Addf.findByIdEnterprise", query = "SELECT a FROM Addf a WHERE a.addfPK.idEnterprise = :idEnterprise"),
    @NamedQuery(name = "Addf.findByAfiliationdate", query = "SELECT a FROM Addf a WHERE a.afiliationdate = :afiliationdate")})
public class Addf implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AddfPK addfPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "AFILIATIONDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date afiliationdate;
    @JoinColumns({
        @JoinColumn(name = "ID_PERSONAL_INFO1", referencedColumnName = "ID_PERSONAL_INFO"),
        @JoinColumn(name = "ID_BRANCHENTERPRISE1", referencedColumnName = "ID_BRANCHENTERPRISE"),
        @JoinColumn(name = "ID_ENTERPRISE1", referencedColumnName = "ID_ENTERPRISE")})
    @OneToOne(fetch = FetchType.LAZY)
    private PersonalInfo personalInfo;
    @JoinColumns({
        @JoinColumn(name = "ID_PERSONAL_INFO", referencedColumnName = "ID_PERSONAL_INFO", insertable = false, updatable = false),
        @JoinColumn(name = "ID_BRANCHENTERPRISE", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private PersonalInfo personalInfo1;

    public Addf() {
    }

    public Addf(AddfPK addfPK) {
        this.addfPK = addfPK;
    }

    public Addf(AddfPK addfPK, Date afiliationdate) {
        this.addfPK = addfPK;
        this.afiliationdate = afiliationdate;
    }

    public Addf(BigInteger idAdd, BigInteger idPersonalInfo, BigInteger idBranchenterprise, BigInteger idEnterprise) {
        this.addfPK = new AddfPK(idAdd, idPersonalInfo, idBranchenterprise, idEnterprise);
    }

    public AddfPK getAddfPK() {
        return addfPK;
    }

    public void setAddfPK(AddfPK addfPK) {
        this.addfPK = addfPK;
    }

    public Date getAfiliationdate() {
        return afiliationdate;
    }

    public void setAfiliationdate(Date afiliationdate) {
        this.afiliationdate = afiliationdate;
    }

    public PersonalInfo getPersonalInfo() {
        return personalInfo;
    }

    public void setPersonalInfo(PersonalInfo personalInfo) {
        this.personalInfo = personalInfo;
    }

    public PersonalInfo getPersonalInfo1() {
        return personalInfo1;
    }

    public void setPersonalInfo1(PersonalInfo personalInfo1) {
        this.personalInfo1 = personalInfo1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (addfPK != null ? addfPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Addf)) {
            return false;
        }
        Addf other = (Addf) object;
        if ((this.addfPK == null && other.addfPK != null) || (this.addfPK != null && !this.addfPK.equals(other.addfPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Addf[ addfPK=" + addfPK + " ]";
    }
    
}
